/**
 * Created by smanukyan on 2/12/14.
 */
define(['angular', 'jQuery', 'services'], function(angular, $){
    return ['$scope', 'images',function ($scope, images){
        $scope.ctrl1 = "controller1";
        $scope.img_path = "";
        $scope.change_size = function(el) {
        };
        images.getImages().then(function(data){
            $scope.images = data.data;
        });
        $scope.addImage = function() {
            var log = [];
            if( $scope.img_path === "" ){
                return;
            }
            angular.forEach($scope.images, function(value, key){
                if( value.img_path === $scope.img_path ){
                    this.push({'img_path': $scope.img_path});
                }
            }, log);

            if( log.length === 0 ) {
                $scope.images.push({'img_path': $scope.img_path});
                $scope.img_path = "";
            } else {
                alert('image has already added');
            }
        };
        $scope.$apply();
    }];
});